package com.jbm.jbmsupplier.zp.liaotian;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.jbm.jbmsupplier.R;
import com.jbm.jbmsupplier.activity.AllActivityApp;
import com.jbm.jbmsupplier.zp.entity.Buddy_ListData;

import org.xutils.image.ImageOptions;
import org.xutils.x;


/**
 * Created by donar_work on 2017/3/28.
 */

public class Personal_InformationActivity extends AllActivityApp {
    private ImageView im_head_portrait;
    private TextView tv_address,tv_name,btn_back;
    private Button btn_sendmsg;

    private Buddy_ListData UserData;

    @Override
    public int setContentView() {
        return R.layout.personal_info;
    }

    @Override
    public void initIalizeView() {
        im_head_portrait = (ImageView) findViewById(R.id.nameimage);
        tv_address = (TextView) findViewById(R.id.tv_address);
        btn_sendmsg = (Button) findViewById(R.id.btn_sendmsg);
        tv_name = (TextView) findViewById(R.id.tv_name);
        btn_back = (TextView) findViewById(R.id.btn_back);
        // im_head_portrait.setOnClickListener(new ClickBtn());
        btn_sendmsg.setOnClickListener(new ClickBtn());
        btn_back.setOnClickListener(new ClickBtn());
        Intent intent = getIntent();
        UserData= (Buddy_ListData)intent.getSerializableExtra("main");
        tv_name.setText(UserData.getNickname());
        if (UserData.getHead_portrait()==null){
            im_head_portrait.setImageDrawable(this.getResources().getDrawable(R.mipmap.pic));

        }else {
            ImageOptions i=new ImageOptions.Builder().setCircular(true).setFailureDrawable(this.getResources().getDrawable(R.mipmap.pic)).build();
            x.image().bind(im_head_portrait,UserData.getHead_portrait(),i);
        }
    }

    class ClickBtn implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.nameimage:
                    break;
                case R.id.btn_sendmsg:
                        Intent intent = new Intent();
                        Bundle bundle = new Bundle();
                        bundle.putSerializable("main",UserData );
                        intent.putExtras(bundle);
                        intent.setClass(Personal_InformationActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                    break;
                case R.id.btn_back:
                    finish();
            }
        }
    }
}
